arch := mips
CC = $(cross)gcc
CFLAGS = -DMYPLAYER=1 -std=gnu99 -I/home/hehj/workspace/865x/source/include -I/home/hehj/workspace/865x/source/include/clearX -I/home/hehj/workspace/865x/source/brow/glib
LDFLAGS = -L/home/hehj/workspace/865x/release/bin
LIBS = msg pthread

sources := main.c readir.c util.c
objects := $(patsubst %.c,%.o,$(sources))
#objects := $(patsubst %.c,%.o,$(wildcard *.c))
lib_lists := $(addprefix -l, $(LIBS)) 
static_lists := /home/hehj/workspace/865x/source/bin/brow/glib/libmyglib.a

ifeq ($(arch),mips)
	cross = mipsel-linux-
else
	cross =
	CFLAGS += -m32
	LDFLAGS += -m32
endif

.PHONY : clean

all : mpctrl test simkey

%.o : %.c
	$(CC) $(CFLAGS) -c $< -o $@

mpctrl : $(objects)
	$(CC) $(LDFLAGS) $(lib_lists) -o $@ $^ $(static_lists)

test : test.o util.o
	gcc test.c util.c -o test

simkey : simkey.o
	$(CC) $(LDFLAGS) $(lib_lists) -o $@ $^

clean:
	rm -rf *.o mpctrl  test

